package cn.bookshare.comment.service;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import cn.bookshare.comment.dao.CommentDao;
import cn.bookshare.comment.vo.Comment;

/**
 * 评论模块业务层代码
 * @author Lijt
 * @version 2017-2-23 下午2:48:31
 */
@Transactional
public class CommentService {
	//注入UserDao
	private CommentDao commentDao;

	public void setUserDao(CommentDao commentDao) {
		this.commentDao = commentDao;
	}
	
	// 添加评论存入数据库
	public void save(Comment comment) {
		this.commentDao.save(comment);
	}
	
	//删除评论
	public void delete(Comment comment) {
		this.commentDao.delete(comment);
	}
	
	//修改评论审核状态
	public void updateCommentFlag(Comment comment) {
		this.commentDao.updateCommentFlag(comment);
	}
	
	/*
	 * search模块
	 */
	// 根据图书id查询评论
	public List<Comment> findByBid(Integer bid) {
		return this.commentDao.findByBid(bid);
	}
	
	// 根据评论用户昵称查询评论
	public List<Comment> findByUserName(String userName) {
		return this.commentDao.findByUserName(userName);
	}
}
